package com.yh.manage.cms.controller;

import com.lxw.api.cms.CmsPageControllerApi;
import com.lxw.framework.domain.cms.CmsPage;
import com.lxw.framework.domain.cms.request.QueryPageRequest;
import com.lxw.framework.domain.cms.response.CmsPageResult;
import com.lxw.framework.model.response.QueryResponseResult;
import com.lxw.framework.model.response.ResponseResult;
import com.yh.manage.cms.service.CmsPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("cms/page/")
public class CmsPageController implements CmsPageControllerApi {

    @Autowired
    private CmsPageService cmsPageService;
    @Override
    @GetMapping("list/{page}/{size}")
    public QueryResponseResult findCmsPagesBypage(@PathVariable Integer page,@PathVariable Integer size, QueryPageRequest queryPageRequest) {
        return cmsPageService.findCmsPagesBypage(page,size,queryPageRequest);
    }
    //添加页面
    @Override
    @PostMapping("add")
    public CmsPageResult addCmsPage(@RequestBody CmsPage cmsPage) {
        return cmsPageService.addCmsPage(cmsPage);
    }

    @Override
    @GetMapping("get/{pageId}")
    public CmsPageResult findCmsPageById(@PathVariable String pageId) {
        return cmsPageService.findCmsPageById(pageId);
    }

    @Override
    @PutMapping("edit/{pageId}")
    public CmsPageResult updateCmsPage(@PathVariable String pageId,@RequestBody CmsPage cmsPage) {
        return cmsPageService.updateCmsPage(pageId,cmsPage);
    }

    @Override
    @DeleteMapping("del/{pageId}")
    public ResponseResult delCmsPageById(@PathVariable String pageId) {
        return cmsPageService.delCmsPageById(pageId);
    }

    @Override
    @PostMapping("/postPage/{pageId}")
    public ResponseResult postPage(@PathVariable String pageId) {
        return cmsPageService.postPage(pageId);
    }

    @Override
    @PostMapping("/save")
    public CmsPageResult saveCmsPage(@RequestBody CmsPage cmsPage) {
        return cmsPageService.saveCmsPage(cmsPage);
    }

    @Override
    @PostMapping("/postPageQuick")
    public ResponseResult postPageQuick(@RequestBody CmsPage cmsPage) {
        return cmsPageService.postPageQuick(cmsPage);
    }
}
